//
//  ZYPopLayerRequest.m
//  DesignMode
//
//  Created by wangzhipan on 2024/11/15.
//

#import "ZYPopLayerRequest.h"

@interface ZYPopLayerRequest()
@end

@implementation ZYPopLayerRequest
- (nonnull instancetype)initWithPopLayerId:(nonnull NSString *)popLayerId
                                  isManual:(BOOL)isManual
                                 showBlock:(nonnull PopLayerShowCmd)showBlock
                                closeBlock:(nonnull PopLayerCloseCmd)closeBlock
                            interruptBlock:(nullable PopLayerInterruptCmd)interruptBlock
                                 resumeCmd:(nullable PopLayerResumeCmd)resumeBlock;
{
    if (self = [super init]) {
        self.popLayerId = popLayerId;
        self.isManual = isManual;
        self.showBlock = showBlock;
        self.closeBlock = closeBlock;
        self.interruptBlock = interruptBlock;
        self.resumeBlock = resumeBlock;
    }
    return self;
}

- (void)doShow
{
    NSLog(@"PopLayer: doShow【%@】", self.popLayerId);
    self.showBlock ? self.showBlock() : nil;
}
- (void)doClose:(BOOL)inQueue
{
    NSLog(@"PopLayer: doClose【%@】", self.popLayerId);
    self.finishBlock ? self.finishBlock() : nil;
    self.closeBlock ? self.closeBlock(inQueue) : nil;
    self.closeBlock = nil;
    self.finishBlock = nil;
    self.showBlock = nil;
    self.interruptBlock = nil;
    self.resumeBlock = nil;
    
}
- (void)doInterrupt
{
    NSLog(@"PopLayer: doInterrupt【%@】", self.popLayerId);
    if (!self.interruptBlock) {
        [self doClose:NO];
    }
    self.interruptBlock ? self.interruptBlock() : nil;
}
- (void)doResume
{
    NSLog(@"PopLayer: doResume【%@】", self.popLayerId);
    self.resumeBlock ? self.resumeBlock() :nil;
}
@end
